package stream;

import lambda.User;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author Klys
 * @Date 2023/4/6
 * @Description
 * @Version 1.0
 */
public class demo01 {

    public static void main(String[] args) {
        List<String> names = Arrays.asList("Alice", "Bob", "Charlie", "Dave");
        User user1 = new User("klys");
        User user2 = new User("liu");
        List<User> users = Arrays.asList(user1, user2);
        String result = names.stream()
                .collect(Collectors.joining("-"));

        System.out.println(result);

        users.stream()
                .map(obj -> {
                    if (obj.getName().equals("klys")) {
                        obj.setName("update");
                    }
                    return obj;
                }).collect(Collectors.toList());
        System.out.println(users);
    }
}
